<!DOCTYPE html>
<html lang="en">
<head>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="UTF-8">
    <title>销售目标预测列表App</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/dist/css/oa-app.css">
    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
        }

        .box-header {
            text-align: center;
            position: fixed;
            left: 1px;
            width: 100%;
            background-color: white;
            padding-top: 6px;
            z-index: 11111;
        }

        .box-header input {
            height: 32px;
            line-height: 31px;
            vertical-align: top;
            border: 1px solid #cbcbcd;
            outline: none;
            margin-left: 2px;
            padding-left: 5px;
        }

        .oa-btn {
            min-width: 44px;
            line-height: 25px;
        }

        .templateStyle {
            margin-top: 5px;
            margin-left: 5px;
            margin-right: 5px;
            box-shadow: 2px 2px 3px #DDDDDD;
        }

        .icon-zhankai, .icon-shouqi {
            cursor: pointer;
            border-radius: 5px;
            float: right;
            font-weight: bold;
            position: absolute;
            right: 15px;
        }

        .hidden {
            display: none;
        }

        .oa-table-title th {
            border-bottom: 0px;
        }

        element.style {
        }

        .icon-zhankai, .icon-shouqi {
            cursor: pointer;
            border-radius: 5px;
            float: right;
            font-weight: bold;
            position: absolute;
            right: 15px;
        }

        .icon-zhankai, .icon-shouqi {
            cursor: pointer;
            border-radius: 5px;
            float: right;
            font-weight: bold;
            position: absolute;
            right: 10px;
        }

        .iconfont {
            font-family: "iconfont" !important;
            font-size: 16px;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            margin-top: 0px;
        }

        .jiaobiao3 {
            position: relative;
        }

        .jiaobiao3 i {
            display: block;
            width: 6px;
            height: 6px;
            background: url("/dist/img/newLog3.png");
            position: absolute;
            top: 0px;
            right: 0px;
        }
        .tryStyle {
            width: 47px;
            height: 15px;
            line-height: 15px;
            font-size: 12px;
            bottom: -1px;
            right: 6px;
            position: absolute;
            border-radius: 50px;
            margin-top: 4px;
            background: #ff131c;
            color: #fff;
            margin-right: -2px;
            transform: scale(0.7);
        }
    </style>
</head>
<body>
<div id="app" v-cloak="">
    <div class="oa-tab-scroll" v-if="companyList.length>1" id="hqCompany">
        <div class="oa-slide ">
            <div v-for="(item,i) in companyList" :class="selectIndex==i? 'tabActive':'tabNo'"
                 @click="getTagByCompanyId(item.id,i);">
                {{item.name}}
            </div>
        </div>
    </div>
    <!--获取区域总监-->
    <div v-if="userInfo.roleName!='区域总监'&&userInfo.roleName!='大区经理'&&managerList.length>=1">
        <div class="oa-tab-small" v-if="companyList.length>1"
             :style="companyList.length>=2?'top:45px;':'top:0px;'" id="hqZJ">
            <!--<div style="margin: 5px 0px 5px 5px;">-->
                <!--<span style="text-align: justify;display: inline-block;overflow: hidden;vertical-align: middle;height: 24px;line-height: 24px;width: 48px;margin-right: 5px;">区域总监<i style="display: inline-block;width: 100%;height: 0;"></i></span>：-->
            <!--</div>-->
            <div :class="selectDepart==0? 'tabActive':'tabNo'"
                  @click="getZjlSaleTargetYc(companyId,selectIndex,'1');">
                全&nbsp;&nbsp;部
            </div>
            <div :class="selectDepart==i+1? 'tabActive':'tabNo'" v-for="(item,i) in managerList"
                  @click="getListByZj(item.id,i);">
              {{item.name}}
            </div>
        </div>
        <div class="oa-tab-scroll" v-else id="hqZJ">
            <div class="oa-slide">
                <div :class="selectDepart==0? 'tabActive':'tabNo'"
                     @click="getZjlSaleTargetYc(companyId,selectIndex,'1');">
                    全&nbsp;&nbsp;部
                </div>
                <div v-for="(item,i) in managerList" :class="selectDepart==i+1? 'tabActive':'tabNo'"
                     @click="getListByZj(item.id,i);">
                    {{item.name}}
                </div>
            </div>
        </div>
    </div>
    <!--获取大区-->
    <div class="oa-tab-scroll" v-if="userInfo.roleName=='区域总监'" style="top: 0px;" id="hqDQ">
        <div class="oa-slide">
            <div :class="selectRegion==0? 'tabActive':'tabNo'"
                  @click="getZjlSaleTargetYc(companyId,selectIndex,'1');">
                全&nbsp;&nbsp;部
            </div>
            <div v-for="departItem in regionList" :class="selectRegion==departItem.bigManagerRegionName? 'tabActive':'tabNo'" v-if="isContainsThree(departItem.bigManagerRegionName)"
                  @click="setBigRegionNames(departItem.bigManagerRegionName,departItem.bigManagerRegionId)">
                {{departItem.bigManagerRegionName}}
            </div>
        </div>
    </div>
    <!--沃源公司获取大区-->
    <div v-if="userInfo.roleName!='区域总监'&&userInfo.roleName!='大区经理'">
        <div class="oa-tab-small" v-if="companyList.length>1||managerList.length>=1" :style="companyList.length>=2?'top:70px;':'top:0px;'" id="hqDQ">
            <!--<div style="margin: 5px 0px 5px 5px;">-->
                <!--<span style="text-align: justify;display: inline-block;overflow: hidden;vertical-align: middle;height: 24px;line-height: 24px;width: 48px;margin-right: 5px;">大区<i style="display: inline-block;width: 100%;height: 0;"></i></span>：-->
            <!--</div>-->
            <div style="float: left;width: calc(100% - 5px);position:static;" class="oa-tab-small"  id="hqDQ">
                <div :class="selectRegion==0? 'tabActive':'tabNo'"
                     @click="getListByZj(managerId,selectDepart-1,0);">
                    全&nbsp;&nbsp;部
                </div>
                <div v-for="departItem in regionList" :class="selectRegion==departItem.bigManagerRegionName? 'tabActive':'tabNo'" v-if="isContainsThree(departItem.bigManagerRegionName)"
                     @click="setBigRegionNames(departItem.bigManagerRegionName,departItem.bigManagerRegionId)">
                    {{departItem.bigManagerRegionName}}
                </div>
            </div>
        </div>
        <div class="oa-tab-scroll" v-else id="hqDQ">
            <div class="oa-slide">
                <div :class="selectRegion==0? 'tabActive':'tabNo'"
                     @click="getZjlSaleTargetYc(companyId,selectIndex,'1');">
                    全&nbsp;&nbsp;部
                </div>
                <div v-for="departItem in regionList" :class="selectRegion==departItem.bigManagerRegionName? 'tabActive':'tabNo'" v-if="isContainsThree(departItem.bigManagerRegionName)"
                     @click="setBigRegionNames(departItem.bigManagerRegionName,departItem.bigManagerRegionId)">
                    {{departItem.bigManagerRegionName}}
                </div>
            </div>
        </div>
    </div>

    <div id="detail" style="margin: 88px 1px 0px 1px;">
        <!--滚滚-->
        <div v-if="loginType=='ggxq'">
            <table class="oa-table " style="margin-top: 5px;">
                <thead>
                <tr class="oa-table-title-gray">
                    <th style="width:105px;background: #d3e8fd;">当月目标</th>
                    <th style="width:120px;background: #d3e8fd;">已完成</th>
                    <!--<th style="width:65px;background: #d3e8fd;">成交总概率</th>-->
                    <th style="background: #d3e8fd;">超75%成交总概率</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td style="width:105px;">{{targetSum}}</td>
                    <td style="width:120px;">{{finishSum}}</td>
                    <!--<td style="width:65px;color: red;border-left: none;">{{scale(allChance,targetSum,finishSum)}}%</td>-->
                    <td style="color: red;border-left: none;">{{scale(overSevenChance,targetSum,finishSum)}}%</td>
                </tr>
                </tbody>
            </table>
        </div>
        <!--沃源-->
        <div v-else>
            <table class="oa-table " style="margin-top: 5px;">
                <thead>
                <tr class="oa-table-title-gray">
                    <th style="width:60px;background: #d3e8fd;">设备类型</th>
                    <th style="width:100px;background: #d3e8fd;">当月目标</th>
                    <th style="width:65px;background: #d3e8fd;">已完成</th>
                    <!--<th style="width:65px;background: #d3e8fd;">成交总概率</th>-->
                    <th style="background: #d3e8fd;">超75%成交总概率</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td class="wyTd" style="background: #F8F8F8;width:60px;">中大挖</td>
                    <td style="width:100px;">{{wyTarget.bigTargetNum}}</td>
                    <td style="width:65px;">{{wyTarget.bigFinishNum}}</td>
                    <!--<td style="width:65px;color: red;border-left: none;">{{scale(bigChance,wyTarget.bigTargetNum,wyTarget.bigFinishNum)}}%</td>-->
                    <td style="color: red;border-left: none;">{{scale(bigOverSevenChance,wyTarget.bigTargetNum,wyTarget.bigFinishNum)}}%</td>
                </tr>
                <tr>
                    <td class="wyTd" style="background: #F8F8F8;width:60px;">小挖</td>
                    <td style="width:100px;">{{wyTarget.smallTargetNum}}</td>
                    <td style="width:65px;">{{wyTarget.smallFinishNum}}</td>
                    <!--<td style="width:65px;color: red;border-left: none;">{{scale(smallChance,wyTarget.smallTargetNum,wyTarget.smallFinishNum)}}%</td>-->
                    <td style="color: red;border-left: none;">{{scale(smallOverSevenChance,wyTarget.smallTargetNum,wyTarget.smallFinishNum)}}%</td>
                </tr>
                </tbody>
            </table>
        </div>
        <div v-for="departItem in departList" v-if="isContains(departItem.bigManagerRegionName)">
            <table class="oa-table " style="margin-top: 5px;">
                <thead>
                <tr class="oa-table-title">
                    <th>{{departItem.bigManagerRegionName}} - <span v-if="departItem.bigManagerName">{{departItem.bigManagerName}}</span><span
                            v-else style="color: red;">空缺</span>
                    </th>
                </tr>
                </thead>
            </table>
            <table class="oa-table">
                <thead>
                <tr class="oa-table-title-gray">
                    <th style="width:60px;">区域</th>
                    <th style="width:45px;">跟踪人</th>
                    <th style="width:55px;">客户姓名</th>
                    <th style="width:65px;">意向机型</th>
                    <th>最新跟踪情况</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in departItem.quYuList" class="oa-lineTwo-H">
                    <td style="width:60px;text-align: left !important;"
                        :rowspan="item.managerRegionNamespan"
                        :class="{hidden: item.managerRegionNamedis}">
                        <div class="oa-lineTwo" @click.stop="showMore($event.target)">
                            {{item.managerRegionName}}
                        </div>
                    </td>
                    <td style="width:45px;" v-if="item.managerName==''&&item.customerName!=''"
                        :rowspan="item.managerRegionNamespan"
                        :class="{hidden: item.managerRegionNamedis}">
                        <div class="oa-name">{{item.genZR}}</div>
                    </td>
                    <td style="width:45px;" v-else
                        :rowspan="item.managerRegionNamespan"
                        :class="{hidden: item.managerRegionNamedis}">
                        <div class="oa-name">{{item.managerName}}</div>
                    </td>
                    <td style="width:55px;text-align: left !important;color: #2a8cec;position: relative;" @click="openDetail(item.customerId,0,'look')">
                        <span  class="oa-name" v-if="item.customerId">
                            {{item.customerName}}
                        </span>
                        <span style="text-align: center" v-if="item.state=='已更新'" class="tryStyle">已更新</span>
                        <span style="text-align: center" v-else></span>
                    </td>
                    <td style="width:65px;text-align: left !important;" class="oa-lineOne"
                        @click.stop="showMore($event.target)">{{item.intentionModel}}
                    </td>
                    <td>
                        <div class="oa-lineTwo" @click.stop="showMore($event.target)">
                            {{item.otherCondition}}
                        </div>
                    </td>
                </tr>

                </tbody>
            </table>
        </div>


    </div>
    <div class="box-header" id="searchDiv">
        <div style="float: left;width: 160px;">
            <select id="testState" v-model="buyDateYc" class="form-control"
                    style=" background-color: white;width:100%;height: 32px;color: #2a8cec;outline: none;border: 1px solid #cbcbcd;padding-left: 2px;">
                <option selected value="">请选择购买时间</option>
                <option selected value="本月内">本月内</option>
                <option selected value="下月内">下月内</option>
            </select>
        </div>
        <div style="float: left;width: 128px">
            <input type="text" id="likeSelect" placeholder="请输入关键字" style="width: 170px"
                   class="form-control pull-left input-sm" v-model="keyYc">
        </div>
        <div style="text-align: center;float: right;margin-right:2px;height: 32px;width: 42px">
            <input type="button" class="btn btn-default pull-left btn-sm"
                   value="查询"
                   class="oaBtn" @click="getZjlSaleTargetYc(companyId,selectIndex)">
        </div>
    </div>
    <div style="margin-top: 15px"></div>
</div>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="https://file.ggxqce.com/web/axios.min.js"></script>

<script src="/dist/js/newOaApp.js"></script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            selectIndex: 0,
            selectDepart: 0,
            selectRegion: 0,
            allHeight: 0,
            currentUserId: getUrlParamObj().userId,
            userInfo: {},
            targetSum: 0,
            finishSum: 0,
            allChance: 0,
            overSevenChance: 0,
            smallChance:0,
            bigChance:0,
            smallOverSevenChance:0,
            bigOverSevenChance:0,
            keyYc: '',
            buyDateYc: '',
            managerId: '',
            regionId: '',
            bigRegionNames: [],
            bigRegionNamesThree: [],
            list: [],
            listChance:[],
            departList: [],
            more: "", //没有展开的item
            companyList: [],
            managerList: [],
            regionList: [],
            wyTarget:{
                smallFinishNum:0,
                smallTargetNum:0,
                bigFinishNum:0,
                bigTargetNum:0
            },
            loginType:'ggxq'
        },
        methods: {
            //查看更多
            showMore: function (event) {
                var el = event
                var text = el.innerText;
                if (text != "") {
                    text = "<i></i>" + text;
                    var mydiv = document.getElementById("oa-more");
                    if (!mydiv) {
                        var div = document.createElement("div");
                        div.setAttribute("id", "oa-more");
                        document.body.appendChild(div);
                        mydiv = document.getElementById("oa-more");
                    }
                    if (mydiv.offsetParent === null) {
                        mydiv.style.display = 'block';
                        mydiv.innerHTML = text;
                        mydiv.style.width = el.offsetWidth + 'px';
                        mydiv.style.left = el.getBoundingClientRect().left + 'px';
                        console.log(el.height)
                        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop || 0;
                        mydiv.style.top = (scrollTop + el.getBoundingClientRect().top + el.offsetHeight + "px")
                    } else {
                        mydiv.style.display = 'none';
                    }

                } else {
                    var mydiv = document.getElementById("oa-more");
                    mydiv.style.display = 'none';
                }

                document.onclick = function () {
                    var mydiv = document.getElementById("oa-more");
                    if (mydiv) {
                        mydiv.style.display = "none";
                    }
                };
            },
            //计算成交总概率
            scale: function (num,targetSum,finishSum) {
                var that = this;
                console.log(num,targetSum,finishSum)
                if ((Number(targetSum) - Number(finishSum)) == 0) {
                    return 100
                } else {
                    return Math.abs((Number(num) / (Number(targetSum) - Number(finishSum))).toFixed(2))

                }
            },
            openDetail: function (customerId, isAdd, pageType) {
                var that = this;
                if(customerId){
                    var isRegion = ''
                    if (this.isSelf == 1) {
                        pageType = "edit"
                        isRegion = 1
                    }
                    var param = {
                        screenType: '0',        //默认竖屏0, 横屏1
                        title: '', //顶部标题
                        url: '/page/intentionManagement/quYuIntentionalDetailApp.html?customerId=' + customerId + '&isAdd=' + isAdd + '&pageType=' + pageType + '&userId=' + that.currentUserId + '&companyId=' + that.companyId + '&isRegion=' + isRegion + '&isSelf=' + that.isSelf + '&newPager=1&yuce=1', //路径
                        showTitleBar: false,     //是否显示标题栏
                        enableRefresh: false   //是否启用下拉刷新
                    }
                    JSBridge.call(ROUTER, 'navigateTo', param)
                }
            },
            isToday: function (item) {
                var that = this;
                var item = item;
                if (!item.customerId || item.customerId == '') {
                    item.state = '';
                } else {
                    if (item.createTime && item.createTime != '') {
                        if (item.createTime.substring(0, 10) == this.getNowDate()) {
                            item.state = "今日新增"
                        } else {
                            if (item.updateTime && item.updateTime != '' && item.updateTime.substring(0, 10) == this.getNowDate()) {
                                item.state = '已更新';
                            } else {
                                item.state = "未更新"
                            }
                        }
                    }
                }
            },
            getNowDate: function () {
                var now = new Date();
                var year = now.getFullYear();
                var month = (now.getMonth() + 1).toString();
                var day = (now.getDate()).toString();
                var hour = (now.getHours()).toString();
                var minute = (now.getMinutes()).toString();
                var second = (now.getSeconds()).toString();
                if (month.length == 1) {
                    month = "0" + month;
                }
                if (day.length == 1) {
                    day = "0" + day;
                }
                if (hour.length == 1) {
                    hour = "0" + hour;
                }
                if (minute.length == 1) {
                    minute = "0" + minute;
                }
                if (second.length == 1) {
                    second = "0" + second;
                }
                var dateTime = year + "-" + month + "-" + day;
                return dateTime;
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '' || list[k][field] == 0 && list[i][field] == 0) {
                                if (field == 'childRegionName') {
                                    if (list[k].regionName == list[i].regionName) {
                                        list[k][field + 'span']++;
                                        list[k][field + 'dis'] = false;
                                        list[i][field + 'span'] = 1;
                                        list[i][field + 'dis'] = true;
                                    }
                                } else if (field == 'quyuName') {
                                    if (list[k].regionName == list[i].regionName && list[k].childRegionName == list[i].childRegionName) {
                                        list[k][field + 'span']++;
                                        list[k][field + 'dis'] = false;
                                        list[i][field + 'span'] = 1;
                                        list[i][field + 'dis'] = true;
                                    }
                                } else {
                                    list[k][field + 'span']++;
                                    list[k][field + 'dis'] = false;
                                    list[i][field + 'span'] = 1;
                                    list[i][field + 'dis'] = true;
                                }
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },
            getListByZj: function (managerId, index,selectRegion) {
                var that = this;
                that.selectDepart = index + 1;
                if (selectRegion){
                    that.selectRegion = selectRegion;
                } else{
                    that.selectRegion = 0;
                }
                if (that.selectDepart == 0){
                    that.getZjlSaleTargetYc(that.companyId,that.selectIndex,'1');
                } else {
                    that.managerId = managerId;
                    var userIds = "";
                    var data = {
                        userId: managerId,
                        companyId: that.companyId,
                    }
                    that.getUserIdInfoById(managerId,userIds,data);
                    //如果是点击的是销售总监兼职的区域总监，则排除掉其他的区域总监的大区
                }
            },
            getRegionListById:function(userId,companyId){
                var that=this;
                var  data={
                    userId: userId,
                    companyId: companyId,
                }
                axios.post('/depConfig/getBigRegionByUserId.json', data)
                    .then(function (r) {
                        var r = r.regionList;
                        that.regionList= r;
                    })
            },
            getUserIdInfoById:function(managerId,userIds,data){
                var that=this;
                var flag=false;
                //判断主职位是否是销售总监
                axios.post('/user/getUserViewById.json', {id: managerId})
                    .then(function (r) {
                        if (r) {
                            if (r.roleName != '区域总监'){
                                flag= true;
                            }else{
                                flag= false;
                            }
                        }else{
                            flag= false;
                        }


                if (flag){
                    for (var i=0;i<that.managerList.length;i++){
                        if (that.managerList[i].id!=managerId){
                            userIds=userIds+","+that.managerList[i].id
                        }
                    }
                    data={
                        userId: managerId,
                        companyId: that.companyId,
                        userIds:userIds,
                    }
                }

                axios.post('/depConfig/getBigRegionByUserId.json', data)
                    .then(function (r) {
                        var r = r.regionList;
                        that.regionList= r;
                        var arrRegionNames = [];
                        var regionIds = "";
                        for (var i = 0; i < r.length; i++) {
                            arrRegionNames.push(r[i].bigManagerRegionName)
                        }
                        that.bigRegionNames = arrRegionNames;
                        that.bigRegionNamesThree = arrRegionNames;
                        for (var i=0;i<r.length;i++){
                            regionIds=regionIds +","+ r[i].bigManagerRegionId
                        }
                        that.getEveryChance(regionIds);
                    })
                    });
            },
            setBigRegionNames:function(regionName,regionId){
                this.selectRegion=regionName;
                this.bigRegionNames = [regionName];
                this.getEveryChance(regionId);
            },
            getZjlSaleTargetYc: function (companyId, i,select) {
                var that = this;
                if (select&&select=='1'){
                    that.selectDepart=0;
                    that.selectRegion=0;
                    that.bigRegionNames=[];
                    that.bigRegionNamesThree=[]
                }
                if (companyId && companyId != '') {
                    that.companyId = companyId;
                }
                if (i && i != '') {
                    that.selectIndex = i;
                } else {
                    that.selectIndex = 0;
                }
                var userId = that.currentUserId;
                JSBridge.call(UI, 'showLoading', {});
                axios.post('/depConfig/getZjlSaleTargetYc.json', {
                    userId: userId,
                    date: that.getNowDate(),
                    companyId: companyId,
                    keyYc: that.keyYc,
                    buyDateYc: that.buyDateYc,
                    regionId: '',
                    managerId: that.managerId
                })
                    .then(function (r) {
                        var r = r;
                        console.log(r)
                        if (r.result && r.result.length > 0) {
                            for (var i = 0; i < r.result.length; i++) {
                                that.isToday(r.result[i]);
                            }
                        }
                        that.list = r.result;
                        if (that.selectDepart==0&&
                            that.selectRegion==0&&
                            that.bigRegionNames.length==0&&
                            that.bigRegionNamesThree.length==0&&
                            that.keyYc == ''
                            &&that.buyDateYc==''){
                            that.listChance = that.tablesMergeCell(r.result);
                        }
                        handlerData(r.result)
                        JSBridge.call(UI, 'hideLoading')
                       if (that.selectRegion != 0) {
                            that.getEveryChance(that.regionId);
                        } else if (that.selectDepart!=0){
                            that.getListByZj(that.managerId,that.selectDepart-1,that.selectRegion)
                        }  else {
                           that.getRegionListById(that.currentUserId,companyId);
                           that.getChance();
                            that.finishSum = r.targetSale.finishSum;
                            that.targetSum = Number(r.targetSale.saleTargetFinish.saleTargetNum);
                            that.wyTarget = r.targetSale.saleTargetFinish;
                            that.getHeight();
                        }
                    })
            },
            isContains: function (regionName) {
                if(this.bigRegionNames.length == 0) return true;
                var res = false;
                for (var i = 0; i < this.bigRegionNames.length; i++) {
                    if (regionName == this.bigRegionNames[i]) {
                        res = true;
                        break;
                    }
                }
                return res;
            },
            isContainsThree: function (regionName) {
                if(this.bigRegionNamesThree.length == 0) return true;
                var res = false;
                for (var i = 0; i < this.bigRegionNamesThree.length; i++) {
                    if (regionName == this.bigRegionNamesThree[i]) {
                        res = true;
                        break;
                    }
                }
                return res;
            },
            //获取区域总监
            getTagByCompanyId: function (companyId, i) {
                var that = this;
                that.keyYc="";
                that.buyDateYc="";
                that.departList = [];
                axios.post('/depConfig/getTagByCompanyId.json ', {
                    companyId: companyId,
                })
                    .then(function (r) {
                        console.log(r)
                        that.managerList = r.managerList;
                        that.managerId = '';
                        that.selectDepart = 0,
                        that.selectRegion = 0,
                            that.getRegionListById(that.currentUserId,companyId);

                        that.getZjlSaleTargetYc(companyId, i,'1');
                    })
            },
            //获取每个大区的概率
            getEveryChance: function (regionId) {
                var that = this;
                that.regionId = regionId;
                that.getTargetAndFinish();
            },
            //计算总概率
            getChance:function(){
                var that=this;
                var smallChance=0;
                var bigChance = 0;
                var smallOverSevenChance = 0 ;
                var bigOverSevenChance = 0;
                var allChance = 0;
                var overSevenChance = 0;
                for (var i = 0; i < that.listChance.length; i++) {
                    if (that.isContains(that.listChance[i].bigManagerRegionName)) {
                        var chanceNum = that.listChance[i].chance.length - 1;
                        if (that.listChance[i].buyDate == '本月内') {
                            //计算小挖的总概率
                            if (that.listChance[i].chance != '<50%'&&that.listChance[i].bucketSize==0) {
                                smallChance = smallChance + Number(that.listChance[i].chance.substring(0, chanceNum))
                            }
                            //计算小挖的超过75概率
                            if (Number(that.listChance[i].chance.substring(0, chanceNum)) >= 75&&that.listChance[i].bucketSize==0) {
                                smallOverSevenChance = smallOverSevenChance + Number(that.listChance[i].chance.substring(0, chanceNum))
                            }
                            //计算大挖的总概率
                            if (that.listChance[i].chance != '<50%'&&that.listChance[i].bucketSize==1) {
                                bigChance = bigChance + Number(that.listChance[i].chance.substring(0, chanceNum))
                            }
                            //计算大挖的超过75概率
                            if (Number(that.listChance[i].chance.substring(0, chanceNum)) >= 75&&that.listChance[i].bucketSize==1) {
                                bigOverSevenChance = bigOverSevenChance + Number(that.listChance[i].chance.substring(0, chanceNum))
                            }
                            if (that.listChance[i].chance != '<50%') {
                                allChance = allChance + Number(that.listChance[i].chance.substring(0, chanceNum))
                            }
                            if (Number(that.listChance[i].chance.substring(0, chanceNum)) >= 75) {
                                overSevenChance = overSevenChance + Number(that.listChance[i].chance.substring(0, chanceNum))
                            }
                        }
                    }
                }
                that.smallChance = smallChance
                that.bigChance = bigChance;
                that.smallOverSevenChance = smallOverSevenChance ;
                that.bigOverSevenChance = bigOverSevenChance;
                that.allChance = allChance;
                that.overSevenChance = overSevenChance;
                JSBridge.call(UI, 'hideLoading')
            },
            //获取大区的目标和完成
            getTargetAndFinish: function () {
                var that = this;
                JSBridge.call(UI, 'showLoading', {});
                axios.post('/depConfig/getTargetAndFinish.json', {
                    userId: that.currentUserId,
                    date: that.getNowDate(),
                    companyId: that.companyId,
                    regionId: that.regionId,
                })
                    .then(function (r) {
                        console.log(r)
                        that.finishSum = r.targetSale.finishSum;
                        that.targetSum = Number(r.targetSale.saleTargetFinish.saleTargetNum);
                        that.wyTarget = r.targetSale.saleTargetFinish;
                        that.getChance();
                    })
            },
            //计算高度
            getHeight: function () {
                var that = this;
                var o1 = document.getElementById("hqCompany");
                var o2 = document.getElementById("hqZJ");
                var o3 = document.getElementById("hqDQ");
                var h1 = 0;
                var h2 = 0;
                var h3 = 0;
                var w2 = 0;
                if (o1) {
                    h1 = o1.offsetHeight;
                }
                if (o2) {
                    h2 = o2.offsetHeight;
                }
                if (o3) {
                    h3 = o3.offsetHeight;
                }
                that.allHeight = Number(h1) + Number(h2) + Number(h3);
                console.log("h1     " + h1);
                console.log("h2     " + h2);
                console.log("h3     " + h3);
                if (Number(h3)>0){
                    document.getElementById("hqDQ").style.top = (Number(h1) + Number(h2)-5) + 'px';
                }
                document.getElementById("searchDiv").style.top = (that.allHeight-5) + 'px';
                document.getElementById("detail").style.marginTop = Number(that.allHeight + 38) + 'px';
            },
        },
        mounted: function () {
            var that = this;
            document.getElementById("searchDiv").style.top = '100px';
            if(server.fwq == "wyp"){
                that.loginType = 'wyp'
            }else{
                that.loginType = 'ggxq'
            }
            var userIds=['201711271733404C9DA1461F2421F828',
                '2017121616084F0B9E200AC4144BD435',
                '2017121616304595BB1D12C91392E04E',
                '2017121618514C22B68296F31AF8DDE2',
                '2017121712504FFC81109A91E681B788',
                '20171217130247059F2B10DB2BE1B5C7',
                '20190218105344E3AB019AC329256BF9',
                '2019040810014F6DB3395FF3674DFCE3',
                '20190418105841A48726641444072F3A',
                '2017121618514C22B68296F31AF8DDE2',
                '20181029131941189298E733B95017AF'];
            for (var i=0;i<userIds.length;i++){
                if (userIds[i]==that.currentUserId){
                    that.currentUserId = '201711271733404C9DA1461F2421F828';
                }
            }
            axios.post('/user/getUserViewById.json', {
                id: that.currentUserId,
            })
                .then(function (res) {
                    var r = res;
                    console.log(r)
                    that.userInfo = r;
                    var excludeCompanyIds = "201712161613432EAF27DBCCB7D0E6CA,2017121910424ED9AA4F786D5549D72F";
                    axios.post('/company/getCompanyListByUserIdAndRegionId.json', {
                        userId: that.currentUserId,
                        excludeCompanyIds: excludeCompanyIds
                    })
                        .then(function (res) {
                            var r = res;
                            if (r && r.length > 0) {
                                for (var i = 0; i < r.length; i++) {
                                    if (r[i].id && r[i].id != '201712161613432EAF27DBCCB7D0E6CA' && r[i].id != '2019011814474FCDB1FC400060A3BEBF') {
                                        that.companyList.push(r[i]);
                                    }
                                }
                            }
                            if (that.companyList && that.companyList.length > 0) {
                                var companyId = that.companyList[0].id;
                                that.getTagByCompanyId(companyId, 0)
                            }
                        })
                })
        }
    })
</script>
<script>
    //navigateBack回调
    function onParamReceived(param) {
        if (param) {
            app.getZjlSaleTargetYc(app.companyId, app.selectIndex);
        }
    }

</script>
<script>
    function handlerData(list) {
        //处理数据
        //1.筛选出大区list
        var departList = []
        var tempDepartId = ""
        for (var i = 0; i < list.length; i++) {
            var item = list[i]
            if (tempDepartId != item.bigManagerRegionId) {
                var departItem = {
                    bigManagerRegionId: item.bigManagerRegionId,
                    bigManagerRegionName: item.bigManagerRegionName,
                    bigManagerName: item.bigManagerName,
                    bigManagerRegionSortNo: item.bigManagerRegionSortNo,
                    quYuList: [],
                    more: ""
                }
                departList.push(departItem)
                tempDepartId = item.bigManagerRegionId
            }
        }
        //console.log(departList)

        //2.给大区添加区域经理
        for (var i = 0; i < list.length; i++) {
            for (var j = 0; j < departList.length; j++) {
                if (departList[j].bigManagerRegionId == list[i].bigManagerRegionId) {
                    departList[j].quYuList.push(list[i])
                }
            }
        }
        console.log(departList)
        for (var i = 0; i < departList.length; i++) {
            departList[i].quYuList = app.tablesMergeCell(departList[i].quYuList);
        }
        app.departList = app.tablesMergeCell(departList);
    }
</script>
</body>
</html>